﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage<IList<Prodma.DataAccess.Models.ViewModels.ArchiveVm>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=System.Configuration.ConfigurationManager.AppSettings["pageTitle"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div class="listHeader">
        <img src="../../Images/ListImages/archivelist.png" alt="" class="listHeaderIco" />
        <div class="listHeaderText">Arşiv Yöneticisi</div>
        
        <div class="listHeaderMenuBox">
            <% Html.RenderPartial("/views/shared/userControls/navigation.ascx",
                   Prodma.DataAccess.Authorization.Authorization.GetNavigation("archive", 17));%>
        </div>
    </div>
    
    <div class="listFindBar">
        <% Html.RenderPartial("/views/shared/userControls/find.ascx",
               new Prodma.DataAccess.Models.UserControlViewModels.FindVm() { View = "archive" });%>
    </div>
    
    <div class="listTitleContainer">
        <div class="listTitleCenter-50">#</div>
        <div class="listTitleCenter-50"><input type="checkbox" id="chk" name="chk" /></div>
        <div class="listTitleLeft-200">Ad</div>
        <div class="listTitleCenter-150">Sıra</div>
        <div class="listTitleCenter-150">Proje</div>
        <div class="listTitleCenter-150">Yayında</div>
        <div class="listTitleCenter-150">Durum</div>
        <div class="listTitleCenter-50">ID</div>
    </div>

    <div class="listRowContainer">
    <% int totalCount = Convert.ToInt32(ViewData["totalRowCount"]) ; %>
    <!-- Bölümlere göre ayrıştırma -->
    <% List<int> archiveCounts = (List<int>)ViewData["archiveCounts"]; %>
    <!-- Listeleme -->
    <% int counter = 1; %>
    <% int seperatorCounter = 0; %>
    <% int same = 0; %>
    <% foreach (int project in (IList<int>)ViewData["projectList"]) %>
    <% { %>
         <% foreach (Prodma.DataAccess.Models.ViewModels.ArchiveVm archive in ViewData.Model) %>
         <% { %>
              <% if (Convert.ToInt32(project) ==  archive.Project.Id) %>
              <% { %>
                   <% same++; %>
                   <% if (counter % 2 != 0) %>
                   <% { %>
                       <div class="listRow1">
                          <div class="listColumnCenter-50"><%=counter %></div>                      
                          <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=archive.Id %>' name="chkSelect" /></div>
                          <div class="listColumnLeft-200">
                            <a href='/archive/edit/?id=<%=archive.Id %>' class="listSelectItemBold">
                                <%=archive.Name%>
                            </a>
                          </div>
                          <div class="listColumnCenter-150">
                             <% if (archive.Order.OrderNo != archiveCounts[seperatorCounter]) %>
                             <% { %>
                                    <a href='/archive/orderUp/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>'><img src="../../Images/ListImages/orderup.png" border="0" alt="" /></a>
                             <% } %>
                             <% else %>
                             <% { %>
                                    <img src="../../Images/ListImages/blankorder.png" alt="" />
                             <% } %>
                             <% if (archive.Order.OrderNo != 1) %>
                             <% { %>
                                    <a href='/archive/orderDown/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>'><img src="../../Images/ListImages/orderdown.png" border="0" alt="" /></a>
                             <% } %>
                             <% else %>
                             <% { %>
                                    <img src="../../Images/ListImages/blankorder.png" alt="" />
                             <% } %>                                
                             <input type="text" id='order<%=counter %>' name="order" value='<%=(archiveCounts[seperatorCounter] + 1) - archive.Order.OrderNo %>' class="listOrderInput" maxlength="5"  />
                             <a href="#" id='aSetOrder<%=counter %>' onclick='setOrder(<%=counter %>)' ><img src="../../Images/ListImages/orderok.png" border="0" alt="" /></a>
                             <input type="hidden" id='hdnSetOrder<%=counter %>' value='/archive/setOrder/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>' />
                          </div>
                          <div class="listColumnCenter-150"><%=archive.Project.Name%></div>
                          <% if (archive.IsLive == true) %>
                          <% { %>
                            <div class="listColumnCenter-150">Yayında</div>
                          <% } %>
                          <% else %>
                          <% { %>
                            <div class="listColumnCenter-150">---</div>
                          <% } %>
                          <div class="listColumnCenter-150"><%=archive.State.Name%></div>
                          <div class="listColumnCenter-50"><%=archive.Id%></div>
                      </div>
                  <% } %>
                  <% else %>
                  <% { %>
                        <div class="listRow2">
                          <div class="listColumnCenter-50"><%=counter %></div>                      
                          <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=archive.Id %>' name="chkSelect" /></div>
                          <div class="listColumnLeft-200">
                            <a href='/archive/edit/?id=<%=archive.Id %>' class="listSelectItemBold">
                                <%=archive.Name%>
                            </a>
                          </div>
                          <div class="listColumnCenter-150">
                             <% if (archive.Order.OrderNo != archiveCounts[seperatorCounter]) %>
                             <% { %>
                                    <a href='/archive/orderUp/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>'><img src="../../Images/ListImages/orderup.png" border="0" alt="" /></a>
                             <% } %>
                             <% else %>
                             <% { %>
                                    <img src="../../Images/ListImages/blankorder.png" alt="" />
                             <% } %>
                             <% if (archive.Order.OrderNo != 1) %>
                             <% { %>
                                    <a href='/archive/orderDown/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>'><img src="../../Images/ListImages/orderdown.png" border="0" alt="" /></a>
                             <% } %>
                             <% else %>
                             <% { %>
                                    <img src="../../Images/ListImages/blankorder.png" alt="" />
                             <% } %>                                
                             <input type="text" id='order<%=counter %>' name="order" value='<%=(archiveCounts[seperatorCounter] + 1) - archive.Order.OrderNo %>' class="listOrderInput" maxlength="5"  />
                             <a href="#" id='aSetOrder<%=counter %>' onclick='setOrder(<%=counter %>)' ><img src="../../Images/ListImages/orderok.png" border="0" alt="" /></a>
                             <input type="hidden" id='hdnSetOrder<%=counter %>' value='/archive/setOrder/?id=<%=archive.Id %>&orderNo=<%=archive.Order.OrderNo %>&project=<%=archive.Project.Id %>' />
                          </div>
                          <div class="listColumnCenter-150"><%=archive.Project.Name%></div>
                          <% if (archive.IsLive == true) %>
                          <% { %>
                            <div class="listColumnCenter-150">Yayında</div>
                          <% } %>
                          <% else %>
                          <% { %>
                            <div class="listColumnCenter-150">---</div>
                          <% } %>
                          <div class="listColumnCenter-150"><%=archive.State.Name%></div>
                          <div class="listColumnCenter-50"><%=archive.Id%></div>
                      </div>
                  <% } %>
                  <% counter++; %>
              <% } // if Project.Id == Archive.Project.Id %>
         <% } // ForEach Archive %>
         <% seperatorCounter++; %>
    <% } // ForEach Project %>
    </div>

    <script type="text/javascript">
        $(function() {
            $('#chk').click(function() {
                $("input[type='checkbox']").attr('checked', $('#chk').is(':checked'));
            });
        });
        function setOrder(counter) {
            var newOrderNo = $('#order' + counter).val();
            if (newOrderNo == '' || newOrderNo <= 0) {
                alert('Yeni sıra numarası pozitif bir sayı olmalıdır !');
                $('#order' + counter).focus();
                return false;
            }
            else {
                var txtOrderNo = $('#order' + counter).val();
                window.location.replace($('#hdnSetOrder' + counter).val() + "&setOrderNo=" + $('#order' + counter).val());
            }
        }
    </script>

</asp:Content>
